package com.demo;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@WebServlet("/ajaxservlet2")
public class AjaxServlet2 extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request, response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
//        request.setCharacterEncoding("UTF-8");
        response.setContentType("text/html;charset=utf-8");
//        response.setCharacterEncoding("utf-8");
        String name = request.getParameter("name");
//        String age = request.getParameter("age");
        String sex = request.getParameter("sex");

        response.getWriter().print("{\"name\":\"落落\",\"hobby\":\"游泳\"}");
        System.out.println("name="+name+"\tsex="+sex);
        System.out.println("hello world");
        System.out.println("hello dog");
        System.out.println("hello chick");
//        System.out.println("hello dog");
//        System.out.println("hello dog");
    }
}
